package com.luming.jedis.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Author Luming
 * @Date 2024/4/3 15:11
 * @Description:
 */
public class JedisConnectionFactory {
    private static final JedisPool jedispool;
    static {
        //配置连接池
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(8);//最大建立连接:8
        jedisPoolConfig.setMaxIdle(8);//最大空闲连接:8
        jedisPoolConfig.setMinIdle(0);//最小空闲连接:0
        jedisPoolConfig.setMaxWaitMillis(1000);//最大等待时间
        
        //建立连接池对象
        jedispool = new JedisPool(jedisPoolConfig,"192.168.81.129",6379,
                1000,"1473992017");
    }
    
    public static Jedis getJedis() {
        return jedispool.getResource();
    }
}
